package com.smaato.xml;

import java.util.Vector;

public class SmaatoXMLResponse 
{
	private String iSuccess;
	private String iErrorCode;
	private String iErrorString;
	private String iUserID;

	private Vector iAds;
	
	public class BeaconInfo
	{
		private String iBeaconUrl;
				
		public String getBeaconUrl()
		{
			return iBeaconUrl;
		}
		
		public void setBeaconUrl(String aUrl)
		{
			iBeaconUrl = aUrl;
		}
	}
	
	public class AdInfo
	{
		private String iAdId;
		private String iAdType;
		private String iRefresh;
		private String iCaching;
		private String iPriority;
		
		private String iValidStart;
		private String iValidEnd;
		private String iValidMax;
		
		private String iLink;
		private String iTarget;
		private String iType;
		private String iAdText;
		private Vector iBeacons;
		
		public AdInfo()
		{
			iBeacons = new Vector();
		}
		
		public void setAdId(String iAdId) 
		{
			this.iAdId = iAdId;
		}
		
		public String getAdId() 
		{
			return iAdId;
		}
		
		public void setAdType(String iAdType) 
		{
			this.iAdType = iAdType;
		}
		
		public String getAdType() 
		{
			return iAdType;
		}
		
		public void setRefreshTime(String iRefresh) 
		{
			this.iRefresh = iRefresh;
		}
		
		public String getRefreshTime() 
		{
			return iRefresh;
		}
		
		public void setCaching(String iCaching) 
		{
			this.iCaching = iCaching;
		}
		
		public String getCaching() 
		{
			return iCaching;
		}
		
		public void setPriority(String iPriority) 
		{
			this.iPriority = iPriority;
		}
		
		public String getPriority() 
		{
			return iPriority;
		}
		
		public void setValidStart(String iValidStart) 
		{
			this.iValidStart = iValidStart;
		}
		
		public String getValidStart() 
		{
			return iValidStart;
		}
		
		public void setValidEnd(String iValidEnd) 
		{
			this.iValidEnd = iValidEnd;
		}
		
		public String getValidEnd() 
		{
			return iValidEnd;
		}
		
		public void setValidMax(String iValidMax) 
		{
			this.iValidMax = iValidMax;
		}
		
		public String getValidMax() 
		{
			return iValidMax;
		}
		
		public void setLink(String aLink)
		{
			iLink = aLink;
		}
		
		public String getLink()
		{
			return iLink;
		}
		
		public void setTarget(String aTarget)
		{
			iTarget = aTarget;
		}
		
		public String getTarget()
		{
			return iTarget;
		}
		
		public void setType(String aType)
		{
			iType = aType;
		}
		
		public String getType()
		{
			return iType;
		}
		
		public void setAdText(String aText)
		{
			iAdText = aText;
		}
		
		public String getAdText()
		{
			return iAdText;
		}
		
		public void addBeacon(BeaconInfo aBeacon)
		{
			iBeacons.addElement(aBeacon);
		}
		
		public Vector getBeacons()
		{
			return iBeacons;
		}
		
		public BeaconInfo getBeacon(int aIndex)
		{
			return (BeaconInfo)iBeacons.elementAt(aIndex);
		}
		
		public int getBeaconCount()
		{
			return iBeacons.size();
		}
	}
	
	public SmaatoXMLResponse()
	{
		iAds = new Vector();
	}
	
	public void setSuccess(String iSuccess) 
	{
		this.iSuccess = iSuccess;
	}
	
	public String getSuccess() 
	{
		return iSuccess;
	}
	
	public void setErrorCode(String errorCode) 
	{
		this.iErrorCode = errorCode;
	}
	
	public String getErrorCode() 
	{
		return iErrorCode;
	}
	
	public void setErrorString(String aErrorString)
	{
		this.iErrorString = aErrorString;
	}
	
	public String getErrorString()
	{
		return iErrorString;
	}
	
	public void setUserID(String iUserID) 
	{
		this.iUserID = iUserID;
	}
	
	public String getUserID() 
	{
		return iUserID;
	}
	
	public void addAd(AdInfo aAd)
	{
		iAds.addElement(aAd);
	}
	
	public Vector getAds()
	{
		return iAds;
	}
	
	public AdInfo getAd(int aIndex)
	{
		return (AdInfo)iAds.elementAt(aIndex);
	}
	
	public int getAdsCount()
	{
		return iAds.size();
	}

	// Debug utility function to print contents
	public void printResponse()
	{
		System.out.println("Success = " + iSuccess);
		System.out.println("UserID = " + iUserID);
		
		for(int i=0; i < iAds.size(); i++)
		{
			AdInfo ad = ((AdInfo)iAds.elementAt(i));
			
			System.out.println("Ad no." + i);
			System.out.println("	AdID = " + ad.getAdId());
			System.out.println("	Ad Type = " + ad.getAdType());
			System.out.println("	Refresh = " + ad.getRefreshTime());
			System.out.println("	Caching = " + ad.getCaching());
			System.out.println("	Priority = " + ad.getPriority());
			System.out.println("	Valid start = " + ad.getValidStart());
			System.out.println("	Valid end = " + ad.getValidEnd());
			System.out.println("	Valid max = " + ad.getValidMax());
			System.out.println("	Link = " + ad.getLink());
			System.out.println("	Target = " + ad.getTarget());
			System.out.println("	Type = " + ad.getType());
			System.out.println("	Ad Text = " + ad.getAdText());
			System.out.println("	Beacons:");
			
			Vector beacons = ((AdInfo)iAds.elementAt(i)).getBeacons();
			for(int j=0; j < beacons.size(); j++)
			{
				System.out.println("		Link = " + ((BeaconInfo)beacons.elementAt(i)).getBeaconUrl());
			}
		}
	}
}
